/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.j2meturk.main;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import javax.microedition.lcdui.*;

public class Tab extends Canvas
{

    private J2METURK pm;

      int selection_tab=0;

    public Tab(J2METURK pm)
    {
        this.pm = pm;
        this.setFullScreenMode(true);

    }
    String data[]={
        "Tab1",
        "Tab2",
        "Tab3",
        "Tab4"
    };

    public void paint(Graphics g)
    {
        //System.out.println("The Paint Method");
        g.setColor(255,255,255);
        g.fillRect(0,0,getWidth(),getHeight());
        g.setColor(255,0,0);
        g.drawRect(0,30,getWidth()-2,getHeight()-60);
        g.setColor(0);
        g.fillRect(1,31,getWidth()-3,getHeight()-61);

        g.setColor(128,128,128);
        g.fillRect(1,32,getWidth()-4,30);

        for(int i=0;i<data.length;i++)
        {
            if(selection_tab==i)
            {
              g.setColor(0,255,0);
              g.fillRoundRect(1+selection_tab*45,32,45,30,5,5);
            }
            g.setColor(255,255,255);
            g.drawString(data[i],2+i*45,35,g.LEFT|g.TOP);
        }
        data(g,selection_tab);

    }
    String tab_data[] = {"J2ME","SYMBIAN","IPHONE","BREW"};
    private void data(Graphics g,int selection)
    {
        g.setColor(255,255,255);
        g.drawString(tab_data[selection], getWidth()/2, getHeight()/2, g.HCENTER|g.TOP);
    }

    public void keyPressed(int keyCode)
    {
        System.out.println("KeyCode is="+keyCode);
        switch(keyCode)
        {
            case -4: // right
                if(selection_tab<data.length-1)
                {
                    selection_tab++;
                }
            break;
            case -3: // left
                if(selection_tab>0)
                {
                    selection_tab--;
                }
            break;
        }
        repaint();
    }
}
